home *** CD-ROM | disk | FTP | other *** search
- # mvext old new
- # rename files with extension old to same names but extension new
- # first some parameter checking
-
- alias queue 'printf "%s %s" \$1 "\$+" => \$1'
- alias localalias "alias \$1 \$+; queue locals \$1"
- alias finish 'unalias \$locals; quit'
- set locals queue localalias finish
-
- ifglobal MAGIC {
- nomagic
- set wasmagic
- }
-
- localalias getbase 'if "." in \$1 {;car -\$?c \$1;} else {cdr -0 \$1;}'
-
- if "$1" = "-o" {
- shift
- set ext .$2
- goto doit
- }
-
- if "$3" != "" {
- rem You should give maximal two parameters
- goto usage
- }
-
- if "$1" = "" {
- usage:
- rem This Batchfile renames files to a different extension
- rem Usage: $0 [-o] (file pattern) [new extension]
- rem Example: $0 *.doc txt
- # Note! : because of the parsing strategy of Master (never evaluate aliased
- # expression inside a false condition) we have to put the brace on a
- # seperate line. So the Master algorithm for brace-counting thinks
- # this is just a local variable block.
- iflocal wasmagic
- {
- magic
- }
- finish
- }
-
- if "$2" != "" {
- if "$2" in "$1" {
- rem Don't be silly!
- goto usage
- }
- set ext .$2
- } else {
- set ext
- }
-
- doit:
- files $1 => allfiles
-
- if not err {
- foreach file in allfiles do
- getbase file => base
- rename $file $base$ext
- endfor
- }
-
- iflocal wasmagic {
- magic
- }
- finish
-